package com.ayf.payment.game.api.channel.youka.util;

import com.ayf.payment.game.api.utils.MD5Util;
import com.swwx.charm.commons.lang.utils.LogPortal;
import org.apache.commons.lang.StringUtils;

import java.text.MessageFormat;

public final class YouKaSignUtil {

    public static String getAgentPayNotifySign(String traceId,String orderid, String status,String amount,String key) {
        String format = "orderid={0}&opstate={1}&ovalue={2}{3}";
        String sign = MessageFormat.format(format,orderid,status,amount,key);
        LogPortal.info("{} 签名原文串:{}",traceId,sign);
        String md5 = MD5Util.strToMd52(sign);
        if (StringUtils.isEmpty(md5)) {
            return null;
        }
        String actualSign = md5.toLowerCase();
        LogPortal.info("{} 实际签名:{}",traceId,actualSign);
        return actualSign;
    }
}
